package GUI;
import Buildings.Buildings;
import Interfaces.*;
import Buildings.dwelling.*;
import Buildings.office.*;
import javax.swing.*;
import java.awt.Component.*;
import java.awt.*;
public class FloorPanel extends javax.swing.JPanel {
    private Floor fl;
    private int floorNumber;
    private BFrame bf;
    //public JButton []Spaces;
    public SpaceButton []Spaces;
    public FloorPanel(Floor f,int num,BFrame bf,int from) {
        initComponents();
        this.bf=bf;
        this.setLayout(new FlowLayout());
        floorNumber=num;
        fl=f;
        //Spaces=new JButton[f.getHowMuchSpaceInFloor()];
        Spaces=new SpaceButton[f.getHowMuchSpaceInFloor()];
        for(int i=0;i<f.getHowMuchSpaceInFloor();i++){
            //Spaces[i]=new JButton(Integer.toString(from));
            Spaces[i]=new SpaceButton(f.getSpaceInFloor(i),from,bf);
            from++;
            this.add(Spaces[i]);
        }
        this.setVisible(true);
        
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBackground(new java.awt.Color(204, 204, 255));
        setBorder(javax.swing.BorderFactory.createEtchedBorder());
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 396, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 296, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        bf.labelFloorArea.setText("Общая площадь: "+fl.getHowMuchAreaInFloor());
        bf.labelFloorNum.setText("Номер этажа: "+ floorNumber);
        bf.labelFloorSpaceNum.setText("Количество помещений: "+fl.getHowMuchSpaceInFloor());
    }//GEN-LAST:event_formMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
